/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class BrowseNode
    {
    
        private String browseNodeIdField;

        private String nameField;

        private Boolean? isCategoryRootField;

        private  BrowseNodeProperties propertiesField;
        private  BrowseNodeChildren childrenField;
        private  BrowseNodeAncestors ancestorsField;
        private  TopSellers topSellersField;
        private  NewReleases newReleasesField;

        /// <summary>
        /// Gets and sets the BrowseNodeId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "BrowseNodeId")]
        public String BrowseNodeId
        {
            get { return this.browseNodeIdField ; }
            set { this.browseNodeIdField= value; }
        }



        /// <summary>
        /// Sets the BrowseNodeId property
        /// </summary>
        /// <param name="browseNodeId">BrowseNodeId property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithBrowseNodeId(String browseNodeId)
        {
            this.browseNodeIdField = browseNodeId;
            return this;
        }



        /// <summary>
        /// Checks if BrowseNodeId property is set
        /// </summary>
        /// <returns>true if BrowseNodeId property is set</returns>
        public Boolean IsSetBrowseNodeId()
        {
            return  this.browseNodeIdField != null;

        }


        /// <summary>
        /// Gets and sets the Name property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Name")]
        public String Name
        {
            get { return this.nameField ; }
            set { this.nameField= value; }
        }



        /// <summary>
        /// Sets the Name property
        /// </summary>
        /// <param name="name">Name property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithName(String name)
        {
            this.nameField = name;
            return this;
        }



        /// <summary>
        /// Checks if Name property is set
        /// </summary>
        /// <returns>true if Name property is set</returns>
        public Boolean IsSetName()
        {
            return  this.nameField != null;

        }


        /// <summary>
        /// Gets and sets the IsCategoryRoot property.
        /// </summary>
        [XmlElementAttribute(ElementName = "IsCategoryRoot")]
        public Boolean IsCategoryRoot
        {
            get { return this.isCategoryRootField.GetValueOrDefault() ; }
            set { this.isCategoryRootField= value; }
        }



        /// <summary>
        /// Sets the IsCategoryRoot property
        /// </summary>
        /// <param name="isCategoryRoot">IsCategoryRoot property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithIsCategoryRoot(Boolean isCategoryRoot)
        {
            this.isCategoryRootField = isCategoryRoot;
            return this;
        }



        /// <summary>
        /// Checks if IsCategoryRoot property is set
        /// </summary>
        /// <returns>true if IsCategoryRoot property is set</returns>
        public Boolean IsSetIsCategoryRoot()
        {
            return  this.isCategoryRootField != null;

        }


        /// <summary>
        /// Gets and sets the Properties property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Properties")]
        public BrowseNodeProperties Properties
        {
            get { return this.propertiesField ; }
            set { this.propertiesField = value; }
        }



        /// <summary>
        /// Sets the Properties property
        /// </summary>
        /// <param name="properties">Properties property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithProperties(BrowseNodeProperties properties)
        {
            this.propertiesField = properties;
            return this;
        }



        /// <summary>
        /// Checks if Properties property is set
        /// </summary>
        /// <returns>true if Properties property is set</returns>
        public Boolean IsSetProperties()
        {
            return this.propertiesField != null;
        }




        /// <summary>
        /// Gets and sets the Children property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Children")]
        public BrowseNodeChildren Children
        {
            get { return this.childrenField ; }
            set { this.childrenField = value; }
        }



        /// <summary>
        /// Sets the Children property
        /// </summary>
        /// <param name="children">Children property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithChildren(BrowseNodeChildren children)
        {
            this.childrenField = children;
            return this;
        }



        /// <summary>
        /// Checks if Children property is set
        /// </summary>
        /// <returns>true if Children property is set</returns>
        public Boolean IsSetChildren()
        {
            return this.childrenField != null;
        }




        /// <summary>
        /// Gets and sets the Ancestors property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Ancestors")]
        public BrowseNodeAncestors Ancestors
        {
            get { return this.ancestorsField ; }
            set { this.ancestorsField = value; }
        }



        /// <summary>
        /// Sets the Ancestors property
        /// </summary>
        /// <param name="ancestors">Ancestors property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithAncestors(BrowseNodeAncestors ancestors)
        {
            this.ancestorsField = ancestors;
            return this;
        }



        /// <summary>
        /// Checks if Ancestors property is set
        /// </summary>
        /// <returns>true if Ancestors property is set</returns>
        public Boolean IsSetAncestors()
        {
            return this.ancestorsField != null;
        }




        /// <summary>
        /// Gets and sets the TopSellers property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TopSellers")]
        public TopSellers TopSellers
        {
            get { return this.topSellersField ; }
            set { this.topSellersField = value; }
        }



        /// <summary>
        /// Sets the TopSellers property
        /// </summary>
        /// <param name="topSellers">TopSellers property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithTopSellers(TopSellers topSellers)
        {
            this.topSellersField = topSellers;
            return this;
        }



        /// <summary>
        /// Checks if TopSellers property is set
        /// </summary>
        /// <returns>true if TopSellers property is set</returns>
        public Boolean IsSetTopSellers()
        {
            return this.topSellersField != null;
        }




        /// <summary>
        /// Gets and sets the NewReleases property.
        /// </summary>
        [XmlElementAttribute(ElementName = "NewReleases")]
        public NewReleases NewReleases
        {
            get { return this.newReleasesField ; }
            set { this.newReleasesField = value; }
        }



        /// <summary>
        /// Sets the NewReleases property
        /// </summary>
        /// <param name="newReleases">NewReleases property</param>
        /// <returns>this instance</returns>
        public BrowseNode WithNewReleases(NewReleases newReleases)
        {
            this.newReleasesField = newReleases;
            return this;
        }



        /// <summary>
        /// Checks if NewReleases property is set
        /// </summary>
        /// <returns>true if NewReleases property is set</returns>
        public Boolean IsSetNewReleases()
        {
            return this.newReleasesField != null;
        }






        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetBrowseNodeId()) {
                xml.Append("<BrowseNodeId>");
                xml.Append(EscapeXML(this.BrowseNodeId));
                xml.Append("</BrowseNodeId>");
            }
            if (IsSetName()) {
                xml.Append("<Name>");
                xml.Append(EscapeXML(this.Name));
                xml.Append("</Name>");
            }
            if (IsSetIsCategoryRoot()) {
                xml.Append("<IsCategoryRoot>");
                xml.Append(this.IsCategoryRoot);
                xml.Append("</IsCategoryRoot>");
            }
            if (IsSetProperties()) {
                BrowseNodeProperties  properties = this.Properties;
                xml.Append("<Properties>");
                xml.Append(properties.ToXMLFragment());
                xml.Append("</Properties>");
            } 
            if (IsSetChildren()) {
                BrowseNodeChildren  children = this.Children;
                xml.Append("<Children>");
                xml.Append(children.ToXMLFragment());
                xml.Append("</Children>");
            } 
            if (IsSetAncestors()) {
                BrowseNodeAncestors  ancestors = this.Ancestors;
                xml.Append("<Ancestors>");
                xml.Append(ancestors.ToXMLFragment());
                xml.Append("</Ancestors>");
            } 
            if (IsSetTopSellers()) {
                TopSellers  topSellers = this.TopSellers;
                xml.Append("<TopSellers>");
                xml.Append(topSellers.ToXMLFragment());
                xml.Append("</TopSellers>");
            } 
            if (IsSetNewReleases()) {
                NewReleases  newReleases = this.NewReleases;
                xml.Append("<NewReleases>");
                xml.Append(newReleases.ToXMLFragment());
                xml.Append("</NewReleases>");
            } 
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}